import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:window_example/page_navigation/page_navigation_cubit.dart';
import 'package:window_example/page_navigation/page_navigation_state.dart';
import 'package:window_example/util/print_util.dart';

import '../util/platform.dart';

class ContentWidget extends StatefulWidget {
  const ContentWidget({super.key});

  @override
  State<ContentWidget> createState() => _ContentWidgetState();
}

class _ContentWidgetState extends State<ContentWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: isDesktop()
          ? Card(
              color: Colors.purple.withOpacity(0.7),
              shadowColor: Colors.purple.shade100,
              child: BlocBuilder(
                  bloc: context.read<PageNavigationCubit>(),
                  builder: (BuildContext context, PageNavigationState state) {
                    LoggerUtil.d(
                        "PageNavigationState:${state.contentPage.toString()}");
                    LoggerUtil.d(
                        "PageNavigationState:${state.contentPage.getContent().toString()}");
                    return state.contentPage.getContent();
                  })

              // SingleChildScrollView(
              //     padding: const EdgeInsets.symmetric(vertical: 0),
              //     child: Column(mainAxisSize: MainAxisSize.max, children: [
              //       BlocBuilder(
              //           bloc: context.read<PageNavigationCubit>(),
              //           builder: (BuildContext context, PageNavigationState state) {
              //             LoggerUtil.d(
              //                 "PageNavigationState:${state.contentPage.toString()}");
              //             return state.contentPage.getContent();
              //           }),
              //     ]))

              )
          : BlocBuilder(
              bloc: context.read<PageNavigationCubit>(),
              builder: (BuildContext context, PageNavigationState state) {
                LoggerUtil.d(
                    "PageNavigationState:${state.contentPage.toString()}");
                LoggerUtil.d(
                    "PageNavigationState:${state.contentPage.getContent().toString()}");
                return state.contentPage.getContent();
              }),
    );
  }
}
